{extend name="public:member" /}
{block name="content"}

<div id="member_content">
	<div class="allWrap">
		<div id="location">
			<div class="allWrap">
				<a href="{$Request.root.true}">首页</a><span>></span><a href="{:url('order_member/index')}">我的订单</a><span>></span><a>订单详情</a>
			</div>
		</div>						
		
		<div id="order_show">
			
			<!--订单状态-->
			<div class="order_status">	
				{//待付款}
				{if condition="$data['order']['order_status_id'] eq config('default_order_status_id') "}			
					
					<ul>
						<li>
							订单号： {$data.order.order_num_alias}<i></i>
							订单状态： <b class="green">{:get_order_status_name($data['order']['order_status_id'])}</b>
						</li>
					</ul>	
				{else/}
					<ul>					
						<li class="line">
							订单号： {$data.order.order_num_alias}<i></i>
							订单状态： <b class="green">{:get_order_status_name($data['order']['order_status_id'])}</b>						
						</li>					
					</ul>
				{/if}			
			</div>
			<!--订单状态 end -->
			
			<!--订单历史 -->
			<h2 class="boxh2">订单历史</h2>
			<div class="box" id="history">		
									
			</div>
			<!--订单历史 end -->
			
			{if condition="$data['order']['shipping_method'] and !empty($data['order']['transport_num'])"}
			<!--订单跟踪 -->
			<h2 class="boxh2">物流信息</h2>
			<div class="box">		
				<ul class="express">
					<li>送货方式：{:osc_system()->get_express($data['order']['transport_c_name'])}</li>
					<li>运单号：{$data.order.transport_num}</li>
					
					<li style="padding-left:25px;margin-top:10px;" id="trace">						
						<a id="trace_b" order_id="{:input('param.id')}" style="margin:10px 0 0 35px; color:#fff; height:20px;background:#06f;font-weight:bold;padding:5px;">点击查询</a>
					</li>
				
				</ul>					
			</div>
			<!--订单跟踪 end -->
			{/if}
			
			<h2 class="boxh2">订单信息</h2>
			<div class="box">
				<ul class="order_contactinfo">
					 {if condition="$data['order']['shipping_method']"}
					<li><b>收货人信息</b>
						<span id="js_addreeshow" rel="">
						
		            	{:get_area_name($data['order']['shipping_province_id'])}，
		            	{:get_area_name($data['order']['shipping_city_id'])}，
		            	{:get_area_name($data['order']['shipping_country_id'])}，
		            	{$data.order.address}，
		            	{$data.order.shipping_name}，
		            	{$data.order.shipping_tel}
						 </span>
					</li>
					{/if}
					<li>
						<b>付款方式</b>
						<span id="js_payshow" pay="1" bank="200">
							{switch name="data.order.payment_code"}    
								{case value="alipay"}支付宝{/case}   
								{case value="weixin"}微信支付{/case}
								{case value="points"}积分兑换{/case}
								{case value="predeposit"}余额支付{/case}
							{/switch}
						</span>
					</li>
					<li>
						<b>订单类型</b>
						<span>
							{:get_goods_type_info(array('type'=>$data['order']['type']),'type')}	
						</span>
					</li>
				</ul>
				<div class="order_pro">
							<h3>商品清单</h3>
							<table width="100%" cellspacing="0" cellpadding="0" border="0">
								<tbody>
									<tr>
									<th colspan="2" class="th1">商品名称</th>
										<th width="83">
											{if condition="$data['order']['type'] eq config('points_goods') "}
												积分
											{else/}
												单价(元)	
											{/if}
										</th>
										<th width="137">商品数量</th>
								
									</tr>
									<?php if(isset($data['order_product'])&&is_array($data['order_product'])){ ?>
										<?php foreach ($data['order_product'] as $product) { ?>
											<tr>
												<td class="td1">
													<a class="img60" href="{:get_goods_type_info(array('type'=>$product['type'],'goods_id'=>$product['goods_id']),'url')}" target="_blank">
													<img class="jsimg"  src="IMG_ROOT{$product.image|resize=60,60}"></a>
												</td>
												<td class="td2 gray">
													<a>{$product.name}</a> 
													<br>
													<?php if($option_list=Db::query('select * from '.config('database.prefix').'order_option where order_goods_id='.$product['order_goods_id'].' and order_id='.$product['order_id'])){ ?>
														<?php foreach ($option_list as $option) { ?>
										                <br />
										                &nbsp;<small> - <?php echo $option['name']; ?>: <?php echo $option['value']; ?></small>
										                <?php } ?>
									                <?php } ?>
												</td>
												<td class="redprice oof">
													{:get_goods_type_info(array('type'=>$data['order']['type'],'price'=>$product['price']),'price')}													
												</td>
												<td><?php echo $product['quantity']; ?></td>					
																						
											</tr>
										<?php } ?>
           						 	<?php } ?>		
								</tbody>
						</table>
					
						{if condition="$data['order']['type'] eq config('points_goods') "}
							<div class="order_price" id="js_order_price">
							
							<div class="total"><em>兑换积分：</em>
								<b class="red">{$data.order.total}</b>
							</div>
					  	 </div>
						{else/}
							<div class="order_price" id="js_order_price">
							<ul>
								 <?php if(isset($data['order_total'])&&is_array($data['order_total'])){ ?>
						          <?php foreach ($data['order_total'] as $totals) { ?>						             
						              	<li><b><?php echo $totals['title']; ?>:</b>
						              		<i>
						                		￥<?php echo $totals['value']; ?>
						                	</i>
						                </li>						          
						          <?php } ?>
					          <?php } ?>								
							</ul>
							<div class="total"><em>应付金额：</em><i class="red">￥</i>
								<b class="red">{$data.order.total}</b>
							</div>
					  	 </div>
						{/if}
						
						
						
				</div>
			</div>	
		</div>
		
	</div>
</div>
{/block}

{block name="javascript"}
<script>	

$('#history').load('<?php echo url("OrderMember/history",array("id"=>input("param.id"))); ?>');

$("#trace_b").click(function(){
	var order_id=$(this).attr('order_id');
	$.ajax({
		url: '{:url("OrderMember/get_trace_info")}', 
		type: 'post',	
		data: {
			order_id:order_id
		},
		dataType: 'json',
		beforeSend: function() {
			$('#trace_b').attr('disabled', true);
			art.dialog({id:'loading',lock: true,title:'加载中'});	
		},	
		complete: function() {
			$('#trace_b').attr('disabled', false);
			art.dialog.list['loading'].close();	
		},			
		success: function(json) {			
			
			if(json.error){
				art.dialog({
					content:json['error'],
					lock: true,
					ok: function () {}				    
				});	
			}else if(json.success){			
				$('#trace').empty();
				$('#trace').append('<iframe name="kuaidi100" src="'+json.url+'" width="600" height="380" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no"></iframe>');
			}else{
				art.dialog({
					content:json['msg'],
					lock: true,
					ok: function () {}				    
				});	
			}
		},
		error: function(xhr, ajaxOptions, thrownError) {
			$('#trace_b').attr('disabled', true);
			alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
		}
	});
	
});


</script>
{/block}